<?php
/**
 * @Author: xuzhiyi
 * @Date:   2016-02-16 20:57:19
 * @Last Modified by:   xuzhiyi
 * @Last Modified time: 2016-03-01 11:47:04
 * ------------------------------------------------ *
 * 订单管理                                            *
 * ------------------------------------------------ */

namespace Admin\Controller;
class OrdersController extends CommonController {


// 订单查询

	public function index(){
		if(IS_AJAX && I('ajax')=="setRefund"){
			$this->setRefund();
		}	
		$m = D('Orders');
    	$PQ = $m->getOrders();
    	$pageSize=(int)I('pageSize',0);
    	if($pageSize>0) $PQ['pageSize']=$pageSize;
    	$page= getPage($PQ['total'],$PQ['pageSize']);
    	$PQ['page'] = $page->show();
    	$this->assign('PQ',$PQ);
    	$this->assign('shopName',I('shopName'));
    	$this->assign('orderNo',I('orderNo'));
    	$this->assign('pageSize',$pageSize);
    	$this->assign('orderStatus',I('orderStatus',-10));
        $this->display();
		
	}

// 退款查询

	public function refund(){
				
		$m = D('Orders');
    	$PQ = $m->getRefund();
    	$pageSize=(int)I('pageSize',0);
    	if($pageSize>0) $PQ['pageSize']=$pageSize;
    	$page= getPage($PQ['total'],$PQ['pageSize']);
    	$PQ['page'] = $page->show();
    	$this->assign('PQ',$PQ);
    	$this->assign('shopName',I('shopName'));
    	$this->assign('orderNo',I('orderNo'));
    	$this->assign('isRefund',I('isRefund',-1));
        $this->display();
	}

// 订单详情

	public function view(){
		
		$m = D('Orders');
		if(I('id')>0){
			$object = $m->getDetail();
			$this->assign('object',$object);
		}
		$this->assign('referer',$_SERVER['HTTP_REFERER']);
		$this->display();
	}


// 退款页面

	public function getRefund(){

		$m = D('Orders');
	    if(I('id')>0){
			$object = $m->getRefundDetail();
			$this->assign('referer',$_SERVER['HTTP_REFERER']);
			$this->assign('object',$object);
		}
		$this->display();
	}

// 退款

    public function setRefund(){
	
		$m = D('Orders');
		$rs = $m->setRefund();
		$this->ajaxReturn($rs);
	}

	public function search(){
		$m = D('Orders');
    	$PQ = $m->getOrders();
    	$pageSize=(int)I('pageSize',0);
    	if($pageSize>0) $PQ['pageSize']=$pageSize;
    	$page= getPage($PQ['total'],$PQ['pageSize']);
    	$PQ['page'] = $page->show();
    	$this->assign('PQ',$PQ);
    	$this->assign('search',I('search'));
    	$this->assign('shopName',I('shopName'));
    	$this->assign('orderNo',I('orderNo'));
    	$this->assign('pageSize',$pageSize);
    	$this->assign('orderStatus',I('orderStatus',-10));
        $this->display('Orders/index');
	}



}